import pika


connection = pika.BlockingConnection()
channel = connection.channel()
channel.exchange_declare(exchange="nreject-exchange",
                         exchange_type="direct",
                         passive=False,
                         durable=False,
                         auto_delete=False)
channel.queue_declare(queue="nreject-queue")
channel.queue_bind(queue="nreject-queue",
                   exchange="nreject-exchange",
                   routing_key="hola")
for n in range(105):
   channel.basic_publish(body="nreject_message" + str(n),
                      exchange="nreject-exchange",
                      routing_key="hola")
delivery = 10
def on_message(channel, method_frame, header_frame, body):
    global delivery
    print(method_frame.delivery_tag)
    if method_frame.delivery_tag == delivery:
        channel.basic_nack(delivery_tag=method_frame.delivery_tag,multiple=True,requeue=False)
        delivery +=10
        print "mutil_reject" + body
#    else:
#        channel.basic_ack(delivery_tag=method_frame.delivery_tag)
    
channel.basic_consume(on_message,'nreject-queue')
try:
    channel.start_consuming()
except KeyboardInterrupt:
    channel.stop_consuming()
connection.close()
